package com.jerry.shop.mapper;

import com.jerry.shop.bean.OrderDetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

//这是OrderDetail操作数据库的mapper
@Mapper
public interface OrderDetailMapper {

    @Select("select * from t_order_detail")
    public List<OrderDetail> getOrderDetailList();

    @Select("select * from t_order_detail where orderId=#{orderId}")
    List<OrderDetail> getOrderDetailListByOrderId(String orderId);

    @Select("select * from t_order_detail where id=#{id}")
    public OrderDetail getOrderDetailById(Integer id);

    @Insert("insert into t_order_detail(id, orderId, productId, productName, productPrice, productQuantity, productIcon) values(#{id}, #{orderId}, #{productId}, #{productName}, #{productPrice}, #{productQuantity}, #{productIcon})")
    public int insertOrderDetail(OrderDetail orderDetail);

    @Update("update t_order_detail set id=#{id}, orderId=#{orderId}, productId=#{productId}, productName=#{productName}, productPrice=#{productPrice}, productQuantity=#{productQuantity}, productIcon=#{productIcon} where id=#{id}")
    public int updateOrderDetail(OrderDetail orderDetail);

    @Delete("delete from t_order_detail where id=#{id}")
    public int deleteOrderDetailById(Integer id);

}
